package o2o.business.sms.dubbo.contest;

import com.jinyouapp.cloud.dubbo.service.RedPacketDubboService;
import jPush.service.JPushServiceInterface;
import o2o.business.sms.dubbo.sms.SMSService;
import o2o.business.sms.dubbo.sms1.SMSService1;
import o2o.business.sms.dubbo.sms2.SMSService2;
import o2o.business.sms.dubbo.sms3.SMSService3;

public class DubboService {
    private static DubboService dubboService = new DubboService();

    private DubboService() {
    }

    public static DubboService getInstance() {
        if (dubboService == null) {
            dubboService = new DubboService();
        }
        return dubboService;
    }

    private SMSService smsService;    //短信
    private SMSService1 smsService1;    //短信
    private SMSService2 smsService2;    //短信
    private SMSService3 smsService3;    //短信
    private JPushServiceInterface jPushServiceInterface;    //极光推送

    private RedPacketDubboService redPacketDubboService;    //红包dubbo测试

    //获取短信服务
    public synchronized SMSService getSmsService() {
        if (smsService == null) {
            synchronized (DubboService.class) {
                if (smsService == null) {
//                    smsService = SpringContextHolder.getBean(Common.smsServiceBean);
                }
            }
        }
        return smsService;
    }

    //获取短信服务
    public synchronized SMSService1 getSmsService1() {
        if (smsService1 == null) {
            synchronized (DubboService.class) {
                if (smsService1 == null) {
//                    smsService1 = SpringContextHolder.getBean(Common.smsServiceBean);
                }
            }
        }
        return smsService1;
    }

    //获取短信服务
    public synchronized SMSService2 getSmsService2() {
        if (smsService2 == null) {
            synchronized (DubboService.class) {
                if (smsService2 == null) {
//                    smsService2 = SpringContextHolder.getBean(Common.smsServiceBean);
                }
            }
        }
        return smsService2;
    }

    //获取短信服务
    public synchronized SMSService3 getSmsService3() {
        if (smsService3 == null) {
            synchronized (DubboService.class) {
                if (smsService3 == null) {
//                    smsService3 = SpringContextHolder.getBean(Common.smsServiceBean);
                }
            }
        }
        return smsService3;
    }

    //获取推送服务
    public synchronized JPushServiceInterface getJPushServiceInterface() {
        if (jPushServiceInterface == null) {
            synchronized (DubboService.class) {
                if (jPushServiceInterface == null) {
//                    jPushServiceInterface = SpringContextHolder.getBean(Common.jPushServiceBean);
                }
            }
        }
        return jPushServiceInterface;
    }

    // 获取红包dubbo调用
    public synchronized RedPacketDubboService getRedPacketDubboService() {
        if (redPacketDubboService == null) {
            synchronized (DubboService.class) {
                if (redPacketDubboService == null) {
//                    redPacketDubboService = SpringContextHolder.getBean("redPacketDubboService");
                }
            }
        }
        return redPacketDubboService;
    }

}
